import os
import cv2


old_path = "../new_images"
new_path = "../new_wrap"
if os.path.exists(new_path):
    print("已存在，不要创建")
else:
    os.mkdir(new_path)

for root, dirs, files in os.walk(old_path):
    for f in files:
        img_path = os.path.join(root, f)
        img = cv2.imread(img_path)
        h, w, _ = img.shape
        if img is not None:
            M = cv2.getRotationMatrix2D(
                (w//2, h//2),
                45,
                0.5
            )
            wrap_img = cv2.warpAffine(
                img, M, (w, h)
            )
            # 保存
            save_img_path = os.path.join(new_path, f)
            cv2.imwrite(save_img_path, wrap_img)


